// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asSoundSourceComponent.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the SoundSourceComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asSoundSourceComponent.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__
#ifdef __COMPILE_WITH_SFML_AUDIO__

#include "../../ScriptHelper.h"
#include "../../core/asEntityComponent.h"

#include "../../../components/sound/SoundSourceComponent.h"


//! Reference factory for the SoundSourceComponent class.
SoundSourceComponent* createSoundSourceComponent(Entity *parent)
{
    return new SoundSourceComponent(parent);
}

//! Binds the SoundSourceComponent class to AngelScript.
void bindSoundSourceComponent(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind SoundSourceComponent class.
    r = engine->RegisterObjectType("SoundSourceComponent", sizeof(SoundSourceComponent), asOBJ_REF); assert(r >= 0);

    // Bind inherited functions.
    bindEntityComponentBase<SoundSourceComponent>(engine, "SoundSourceComponent");

    // Set SoundSourceComponent behaviour.
    r = engine->RegisterObjectBehaviour("SoundSourceComponent", asBEHAVE_FACTORY, "SoundSourceComponent@ f(Entity @+)",
                                        asFUNCTION(createSoundSourceComponent), asCALL_CDECL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SoundSourceComponent", "SoundSourceComponent& opAssign(const SoundSourceComponent &in)",
                                     asFUNCTION(assignT<SoundSourceComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0);

    // Bind SoundSourceComponent class functions.
    r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadMusic(const string &in)",
                                     asMETHOD(SoundSourceComponent, loadMusic), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadSoundBuffer(const string &in)",
                                     asMETHOD(SoundSourceComponent, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SoundSourceComponent", "void play()",
                                     asMETHOD(SoundSourceComponent, play), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void pause()",
                                     asMETHOD(SoundSourceComponent, play), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void stop()",
                                     asMETHOD(SoundSourceComponent, play), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SoundSourceComponent", "f32 getAttenuation()",
                                     asMETHOD(SoundSourceComponent, getAttenuation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "bool getIsPlaying()",
                                     asMETHOD(SoundSourceComponent, getIsPlaying), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "bool getIsPaused()",
                                     asMETHOD(SoundSourceComponent, getIsPaused), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "bool getIsStopped()",
                                     asMETHOD(SoundSourceComponent, getIsStopped), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "f32 getMinDistance()",
                                     asMETHOD(SoundSourceComponent, getMinDistance), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "f32 getOffset()",
                                     asMETHOD(SoundSourceComponent, getOffset), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "f32 getPitch()",
                                     asMETHOD(SoundSourceComponent, getPitch), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "f32 getVolume()",
                                     asMETHOD(SoundSourceComponent, getVolume), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SoundSourceComponent", "void setAttenuation(f32)",
                                     asMETHOD(SoundSourceComponent, setAttenuation), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void setLoop(bool)",
                                     asMETHOD(SoundSourceComponent, setLoop), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void setMinDistance(f32)",
                                     asMETHOD(SoundSourceComponent, setMinDistance), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void setOffset(f32)",
                                     asMETHOD(SoundSourceComponent, setOffset), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void setPitch(f32)",
                                     asMETHOD(SoundSourceComponent, setPitch), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SoundSourceComponent", "void setVolume(f32)",
                                     asMETHOD(SoundSourceComponent, setVolume), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_SFML_AUDIO__
#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
